package ar.edu.test;

import java.io.PrintStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;

public class ClaseLoader {
	
	private String packageName;
	private String name;
	private String simpleName;
	private String canonicalName;
	private List<Field> fields;
	private List<Method> methods;
	
	private static PrintStream out = System.out;
	
	public void loadDataClass(Class clase){
		packageName = clase.getPackage().getName();
		name = clase.getName();
		simpleName = clase.getSimpleName();
		canonicalName = clase.getCanonicalName();
		fields = Arrays.asList(clase.getDeclaredFields());
		methods = Arrays.asList(clase.getDeclaredMethods());
	}
	
	public void printDataClass(){
		out.println("packageName: " + packageName);
		out.println("name: " + name);
		out.println("simpleName: " + simpleName);
		out.println("canonicalName: " + canonicalName);
		out.println("Fields:");
		for(Field f : fields){
			out.println("Name: " + f.getName());
			out.println("Type: " + f.getType().getName());
		}
		out.println("Methods:");
		for(Method m : methods){
			out.println("Name: " + m.getName());
			out.println("Return Type: " + m.getGenericReturnType().toString());	
		}
	}



}
